// Package camp_homework
// Created by GoLand
// @User: lenora
// @Date: 2023/11/26
// @Time: 22:59

package main

import "fmt"

//Delete
//暂时未考虑到缩容的功能以及多个元素的功能
func Delete[T AllowType](index uint, group []T) []T {
	if len(group) <= 0 {
		panic("length error")
	}
	if index >= uint(len(group)) {
		panic("index error")
	}

	res := make([]T, len(group)-1, len(group)-1)
	//fmt.Printf("origin address:%p\n", &res)
	copy(res, group[0:index])
	//fmt.Printf("address1:%p\n", &res)
	copy(res[index:], group[index+1:])
	//fmt.Printf("address2:%p\n", &res)
	return res
}

type AllowType interface {
	string |
		int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64
}

func main() {
	res := Delete[string](4, []string{"a", "b", "c", "d", "e"})
	fmt.Printf("res:%v, length:%d, cap:%d", res, len(res), cap(res))
}
